package org.ourgrid.acceptance.util.aggregator;

import java.util.List;

import org.hibernate.Criteria;
import org.ourgrid.acceptance.util.AggregatorAcceptanceUtil;
import org.ourgrid.aggregator.AggregatorComponent;
import org.ourgrid.common.statistics.beans.aggregator.monitor.AG_PeerStatusChange;
import org.ourgrid.common.statistics.util.hibernate.HibernateUtil;

import br.edu.ufcg.lsd.commune.context.ModuleContext;

public class Req_604_Util extends AggregatorAcceptanceUtil {

	public Req_604_Util(ModuleContext context) {
		super(context);
	}
	
	@SuppressWarnings("unchecked")
	public List<AG_PeerStatusChange> getPeerStatusChanges(AggregatorComponent component) {
		
		HibernateUtil.beginTransaction();
		
		List<AG_PeerStatusChange> changes = null;
		
		try {
			Criteria criteria = HibernateUtil.getSession().createCriteria(AG_PeerStatusChange.class);
			changes = criteria.list();
			HibernateUtil.commitTransaction();
		} catch (Exception e) {
			HibernateUtil.rollbackTransaction();
			throw new RuntimeException(e);
		}
		
		return changes;
		
	}

}
